package com.vini.web;

import org.apache.wicket.Page;
import org.apache.wicket.Session;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.request.Request;
import org.apache.wicket.request.Response;
import org.apache.wicket.settings.IRequestCycleSettings.RenderStrategy;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;

import com.vini.web.pages.BasePage;
import com.vini.web.pages.CompletedRides;
import com.vini.web.pages.CreateCircle;
import com.vini.web.pages.Home;
import com.vini.web.pages.ManageCircles;
import com.vini.web.pages.NewRides;
import com.vini.web.pages.Payment;
import com.vini.web.pages.PendingRides;
import com.vini.web.pages.SignIn;
import com.vini.web.pages.SignUp;
import com.vini.web.pages.TaxiLinkManual;
import com.vini.web.pages.UserPreferences;

public class WicketApplication extends WebApplication {

	@Override
	public Class<? extends Page> getHomePage() {
		return Home.class;
	}
	
	@Override
	protected void init() {
		createBookmarks();
		initSpringSupport();
		//setRootRequestMapper(new HttpsMapper(getRootRequestMapper(), new HttpsConfig(8180, 8443)));
		getRequestCycleSettings().setRenderStrategy(RenderStrategy.ONE_PASS_RENDER);
		getMarkupSettings().setCompressWhitespace(true);
	}
	
	private void initSpringSupport() {
		getComponentInstantiationListeners().add(new SpringComponentInjector(this));
	}

	private void createBookmarks() {
		mountPage("/home", Home.class);
		mountPage("/signin", SignIn.class);
		mountPage("/signup", SignUp.class);
		mountPage("/newRides", NewRides.class);
		mountPage("/completedRides", CompletedRides.class);
		mountPage("/pendingRides", PendingRides.class);
		mountPage("/createCircle", CreateCircle.class);
		mountPage("/manageCircles", ManageCircles.class);
		mountPage("/payment", Payment.class);
		mountPage("/taxiLinkManual", TaxiLinkManual.class);
		mountPage("/preferences", UserPreferences.class);
		
		//mountPage("/home", Home.class);
		//mountPage("/home", Home.class);
		//mountPackage("/", BasePage.class);
		
	}

	@Override
	public Session newSession(Request request, Response response) {
		return new AppSession(request); 
	}
	

}
